/**
 * 
 */
package cl.whyem.appbase.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cl.whyem.appbase.entities.User;
import cl.whyem.appbase.services.UserService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author Siva
 *
 */
@Controller
public class UserController {

	@Autowired
	private UserService userService;
	
	@RequestMapping("/welcome")
	public String welcome(Model model) 
	{
		List<User> blogs = userService.findAllUsers();
		model.addAttribute("USERS", blogs);
		return "welcome";
	}
        
        @RequestMapping(method = RequestMethod.POST)
        public ModelAndView add(HttpServletRequest request, HttpServletResponse response) {
            User user = new User();
            user.setUserId(1);
            //ModelAndView >> PAG. RETORNO / ALIAS MODEL / OBJECT MODEL
            return new ModelAndView("paginaRetorno", "user", user);
        }
}
